<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('创业板股票列表')"/>
</head>
<style>
    /*.table{*/
    /*    table-layout: fixed;*/
    /*}*/
    .table td:hover{
        overflow: visible;
        white-space: normal;
    }
    .table td {
        word-wrap: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
</style>

<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>股票代码：</label>
                            <input type="text" name="stockCode"/>
                        </li>
                        <li>
                            <label>股票名称：</label>
                            <input type="text" name="stockName"/>
                        </li>
<!--                        <li>-->
<!--                            <label>股票板块：</label>-->
<!--                            <input type="text" name="stockSector"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>突围次数：</label>-->
<!--                            <input type="text" name="previousBreakFrequency"/>-->
<!--                        </li>-->

<!--                        <li class="select-time">-->
<!--                            <label>突围时间： </label>-->
<!--                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"-->
<!--                                   name="params[beginTime]"/>-->
<!--                            <span>-</span>-->
<!--                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"-->
<!--                                   name="params[endTime]"/>-->
<!--                        </li>-->

                        <li>
                            是否购买：<select name="purchaseLevel" th:with="type=${@dict.getType('sys_stock_disable')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:board:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:board:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:board:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:board:export">
                <i class="fa fa-download"></i> 导出
            </a>
            <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:user:import">
                <i class="fa fa-upload"></i> 导入
            </a>
            <a class="btn btn-info" onclick="javascript:batchStockMainBoardDetail()"
               shiro:hasPermission="system:user:import">
                <i class="fa fa-upload"></i> AI生成创业板股票
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var detailFlag = [[${@permission.hasPermi('system:board:edit')}]];
    var editFlag = [[${@permission.hasPermi('system:board:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:board:remove')}]];
    var prefix = ctx + "system/second/board";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            detailUrl: prefix + "/detail/{id}",
            importTemplateUrl: prefix + "/importTemplate",
            modalName: "股票主板",
            columns: [{
                checkbox: true
            },
                {
                    field: 'mainId',
                    title: '主板ID',
                    visible: false
                },
                {
                    field: 'stockCode',
                    title: '股票代码'
                },
                {
                    field: 'stockName',
                    title: '股票名称'
                },
                {
                    field: 'warmUpFrequencyTime',
                    title: '热身时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'leftFistFrequencyTime',
                    title: '左拳时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'rightFistFrequencyTime',
                    title: '右拳时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'embattleFrequencyTime',
                    title: '布阵时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'assaultFrequencyTime',
                    title: '袭击时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'breakFrequencyTime',
                    title: '冲锋时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'streetBattleFrequencyTime',
                    title: '巷战时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'reversionFrequencyTime',
                    title: '逆转时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'qualitativeChangeFrequencyTime',
                    title: '质变时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },
                {
                    field: 'revolutionFrequencyTime',
                    title: '革命时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === null || value === undefined || value === "") {
                            return value;
                        } else {
                            const month = value.substring(5, 7);
                            const day = value.substring(7, 11);
                            console.log(month);
                            const formattedDate = `${month}${day}`;
                            return formattedDate;
                        }
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.mainId + '\')"><i class="fa fa-search"></i>详细</a>');
                        return actions.join('');
                    }
                },

                {
                    visible: editFlag == 'hidden' ? false : true,
                    title: '是否购买',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                }


            ]
        };
        $.table.init(options);
    });

    function batchStockMainBoardDetail() {

        $.modal.confirm("确认要生成创业板股票细节表数据吗?", function () {
            location.href = prefix + "/batchStockSecondBoardDetail";
            layer.msg('执行成功,正在生成代码请稍候…', {icon: 1});
        });
    }

    /* 是否购买显示 */
    function statusTools(row) {
        if (row.purchaseLevel == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.mainId + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.mainId + '\')"></i> ';
        }
    }

    /* 是否购买-停用 */
    function disable(mainId) {
        $.modal.confirm("确认要停用购买吗？", function () {
            $.operate.post(prefix + "/changeStatus", {"mainId": mainId, "purchaseLevel": 1});
        })
    }

    /* 是否购买启用 */
    function enable(mainId) {
        $.modal.confirm("确认要启用购买吗？", function () {
            $.operate.post(prefix + "/changeStatus", {"mainId": mainId, "purchaseLevel": 0});
        })
    }

</script>
</body>

<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport"
                       title="如果登录账户已经存在，更新这条数据。">
                &nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i
                    class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>